package com.simpou.commons.utils.file;

import com.simpou.commons.utils.file.VelocityHelper;
import com.simpou.commons.utils.tests.TestRunner;
import com.simpou.commons.utils.tests.annot.ClassTest;
import static org.junit.Assert.*;

import org.junit.Test;

import org.junit.runner.RunWith;


@ClassTest(VelocityHelper.class)
@RunWith(TestRunner.class)
public class VelocityHelperITCase {
    @Test
    public void testSetParameter() {
        //testMerge
    }

    @Test
    public void testMerge() throws Exception {
        VelocityHelper template = new VelocityHelper("TestVelocityTemplate.vsl");
        String msg = "Hello velocity";
        String msgMerged = "Message: " + msg + "\r\nType: type ";
        String msgMergedType1 = msgMerged + "1\r\n";
        String msgMergedType2 = msgMerged + "2\r\n";
        String source;

        template.setParameter("msg", msg);
        template.setParameter("type", true);
        source = template.merge();
        assertEquals(msgMergedType1, source);

        template.setParameter("type", false);
        source = template.merge();
        assertEquals(msgMergedType2, source);

        // somente para cobrir teste para o caso do ENGINE já estar inicializado.
        VelocityHelper template2 = new VelocityHelper(
                "TestVelocityTemplate.vsl");
    }
}
